﻿using System;
using System.Collections.Generic;
using System.Windows.Forms;
using DevExpress.XtraBars;
using DevExpress.XtraGrid.Views.Base;
using System.Drawing;

namespace QLKS
{
    public partial class frmMain : DevExpress.XtraBars.Ribbon.RibbonForm
    {
        public static frmMain _frmMain;        
        public static frmDangNhap frmDangNhap;
        public frmMain()
        {
            InitializeComponent();
        }
        private void FormMain_FormClosed(object sender, FormClosedEventArgs e)
        {
            if (frmDangNhap != null)
                frmDangNhap.Close();
        }
        public static void closeForms()
        {
            foreach (Form f in _frmMain.MdiChildren)
            {
                f.Close();
            }
        }
        public static Boolean sameForm(string frmname)
        {
            foreach (Form a in _frmMain.MdiChildren)
            {
                if (a.Name.Equals(frmname))
                {
                    a.Activate();
                    return true;
                }
            }
            return false;
        }
        private void FormMain_Load(object sender, EventArgs e)
        {
            _frmMain = this;
            frmTinhTrangPhong tinhtrang = new frmTinhTrangPhong() { MdiParent = this };
            tinhtrang.Show();
        }
        private void btnKhachHang_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (!sameForm("frmQLKhachHang"))
            {
                Form f = new frmQLKhachHang { MdiParent = this };
                f.Show();
            }
        }

        private void btnLoaiKhach_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (!sameForm("frmQLLoaiKhachHang"))
            {
                Form f = new frmQLLoaiKhachHang { MdiParent = this };
                f.Show();
            }
        }

        private void btnBaoCaoMatDo_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (!sameForm("frmBaoCaoMatDo"))
            {
                frmBaoCaoMatDo bcmd = new frmBaoCaoMatDo() { MdiParent = this };
                bcmd.Show();
            }
        }

        private void btnBaoCaoDoanhThu_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (!sameForm("frmBaoCaoDoanhThu"))
            {
                frmBaoCaoDoanhThuNew bcmd = new frmBaoCaoDoanhThuNew() { MdiParent = this };
                bcmd.Show();
            }
        }

        private void btnPhong_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (!sameForm("frmLapDanhMucPhong"))
            {
                frmLapDanhMucPhong bcmd = new frmLapDanhMucPhong() { MdiParent = this };
                bcmd.Show();
            }
        }

        private void btnTCPhong_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (!sameForm("fmrTraCuuPhong"))
            {
                fmrTraCuuPhong bcmd = new fmrTraCuuPhong() { MdiParent = this };
                bcmd.Show();
            }
        }

        private void btnTinhTrangPhongMoi_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (!sameForm("frmTinhTrangPhong"))
            {
                frmTinhTrangPhong bcmd = new frmTinhTrangPhong() { MdiParent = this };
                bcmd.Show();
            }
        }

        private void btnBCTTTMatDo_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (!sameForm("frmBaoCaoDoanhThu"))
            {
                frmBaoCaoDoanhThu bcmd = new frmBaoCaoDoanhThu() { MdiParent = this };
                bcmd.Show();
            }            
        }

        private void btnLapHoaDon_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (!sameForm("frmLapHoaDon"))
            {
                frmLapHoaDon f = new frmLapHoaDon() { MdiParent = this };
                f.Show();
            }    
        }

        private void btnLapHoaDonMoi_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (!sameForm("frmLapHoaDon"))
            {
                frmLapHoaDonNew f = new frmLapHoaDonNew() { MdiParent = this };
                f.Show();
            }  
        }
        
        private void btnLapPhieuThue_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (!sameForm("frmTaoPhieuThue"))
            {
                frmTaoPhieuThue f = new frmTaoPhieuThue() { MdiParent = this };
                f.Show();
            }  
        }

        private void btnLapPhieuThueMoi_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (!sameForm("frmLapPhieuThuePhong"))
            {
                frmLapPhieuThuePhong f = new frmLapPhieuThuePhong() { MdiParent = this };
                f.Show();
            }  
        }
        
        private void btnQuyDinh_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (!sameForm("frmThayDoiQuiDinh"))
            {
                frmThayDoiQuiDinh f = new frmThayDoiQuiDinh() { MdiParent = this };
                f.Show();
            }  
        }
    }
}